import sys
import log

class ExceptionMappingGPCS():
    __guid__ = 'gpcs.ExceptionMapping'

    def CallDown(self, packet):
        try:
            return self.ForwardCallDown(packet)
        except GPSTransportClosed, e:
            (exctype, exc, tb,) = sys.exc_info()
            try:
                if (getattr(e, 'reasonCode', None) and mls.HasLabel(('MACHONET_TRANSPORTCLOSED_' + e.reasonCode))):
                    raise UserError(getattr(mls, ('MACHONET_TRANSPORTCLOSED_' + e.reasonCode)), (getattr(e, 'reasonDict', {}) or {})), None, tb
                raise UserError('GPSTransportClosed', {'what': e.reason}), None, tb

            finally:
                exctype = None
                exc = None
                tb = None

        except UnMachoDestination, e:
            (exctype, exc, tb,) = sys.exc_info()
            try:
                raise UserError('UnMachoDestination', {'what': e.payload}), None, tb

            finally:
                exctype = None
                exc = None
                tb = None




    def NotifyDown(self, packet):
        try:
            return self.ForwardNotifyDown(packet)
        except GPSTransportClosed, e:
            (exctype, exc, tb,) = sys.exc_info()
            try:
                if (getattr(e, 'reasonCode', None) and mls.HasLabel(('MACHONET_TRANSPORTCLOSED_' + e.reasonCode))):
                    raise UserError(getattr(mls, ('MACHONET_TRANSPORTCLOSED_' + e.reasonCode)), (getattr(e, 'reasonDict', {}) or {})), None, tb
                raise UserError('GPSTransportClosed', {'what': e.reason}), None, tb

            finally:
                exctype = None
                exc = None
                tb = None

        except UnMachoDestination, e:
            (exctype, exc, tb,) = sys.exc_info()
            try:
                raise UserError('UnMachoDestination', {'what': e.payload}), None, tb

            finally:
                exctype = None
                exc = None
                tb = None





